/*
 * Copyright (c) 2022-2023 cetcclout Co., Ltd All rights reserved.
 * Sensor Adapter is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package com.cetccloud.cimp.adapter.datasource.sqldb.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.cetccloud.cimp.adapter.datasource.sqldb.dao.EnvRuleHj212Dao;
import com.cetccloud.cimp.adapter.datasource.sqldb.entity.EnvRuleHj212Entity;
import com.cetccloud.cimp.adapter.datasource.sqldb.service.EnvRuleHj212Service;
import com.cetccloud.cimp.common.util.SensorStringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


/**
 * @author
 * @apiNote 数据协议属性关联服务
 * @date 2023-03-16 09:07:30
 */
@Service("envRuleHj212Service")
@DS("env")
public class EnvRuleHj212ServiceImpl extends ServiceImpl<EnvRuleHj212Dao, EnvRuleHj212Entity> implements EnvRuleHj212Service {

    /**
     * 加载配置信息
     */
    public JSONArray getConfig(String tableName){
        if(SensorStringUtils.isNotEmpty(tableName)) {
            List<Map> configList = this.baseMapper.getConfig(tableName);
            if (ObjectUtil.isEmpty(configList)) {
                return null;
            }else {
                return JSONUtil.parseArray(JSONUtil.toJsonStr(configList));
            }
        }
        return null;
    }


}